package com.qf.test.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.test.pojo.DtsAccountTrace;
import com.qf.test.service.BrokerageService;
import com.qf.test.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//佣金列表首页
//解决跨域问题
@CrossOrigin("*")
//这个类交给spring管理
@RestController
//类的访问路径
@RequestMapping("/BrokerageContller")
public class BrokerageContller {
    @Autowired
    private BrokerageService brokerageService;
    @RequestMapping("/list")
    public Object list(){
        //1.从service层查询数据返回
        IPage<DtsAccountTrace> findall = brokerageService.findall();
        //获取返回的条数
        long total = findall.getTotal();
        //获取返回的数据
        List<DtsAccountTrace> list = findall.getRecords();
        //返回数据给前端
        Map<String, Object> data = new HashMap<>();
            data.put("total",total);
            data.put("traceList",list);
        return ResponseUtil.ok(data);
    }

}
